﻿<MudTabs Elevation="1" @ref="_tabElement" AlwaysShowScrollButtons="AlwaysShowScrollButtons" Position="Position">
@foreach (var tab in _tabs)
{
    <MudTabPanel @key="tab" Text="@tab">
        <MudText>@tab</MudText>
    </MudTabPanel>
}
</MudTabs>

@code
{
    public static string __description__ = "scrolling should work";

    private MudTabs _tabElement = null!;
    private readonly List<string> _tabs = ["1", "2", "3", "4", "5", "6"];

    [Parameter]
    public Position Position { get; set; } = Position.Top;

    [Parameter]
    public bool AlwaysShowScrollButtons { get; set; } = true;

    public void SetPanelActive(int index)
    {
        InvokeAsync(() => _tabElement.ActivatePanel(index));
    }

    public Task AddPanel()
    {
        _tabs.Add("new item");
        return InvokeAsync(StateHasChanged);
    }

    public Task RemovePanel(int index)
    {
        _tabs.RemoveAt(index);
        return InvokeAsync(StateHasChanged);
    }
}
